package com.yixinsoft.basic.common.exception;

/**
 * Created by hqy on 2015/8/18.
 */
public class CustomException extends Exception {
	
	private static final long serialVersionUID = 1L;
	
	private int errorCode;

    public int getErrorCode() {
        return errorCode;
    }

    private void setErrorCode(int errorCode) {
        this.errorCode = errorCode;
    }

    public CustomException(Errors error) {
        super(error.getDescription());
        setErrorCode(error.getErrorCode());
    }

    public CustomException(String message) {
        super(message);
        setErrorCode(Errors.ServerError.getErrorCode());
    }

    public CustomException(Errors error, String message) {
        super(message);
        setErrorCode(error.getErrorCode());
    }

    public CustomException(Errors error, Throwable cause) {
        super(error.getDescription(), cause);
        setErrorCode(error.getErrorCode());
    }

    public CustomException(Errors error, String message, Throwable cause) {
        super(message, cause);
        setErrorCode(error.getErrorCode());
    }
}
